namespace ghost
{
    /**攻击条件筛选*/
    export class PeakType
    {
        static NONE=-1;
        /**最大血量*/static MAX_HP=1;
        /**最小血量*/static MIN_HP=2;
        /**最大距离*/static MIN_DISTANCE=3;
        /**锁定位置*/static LOCK_POSITION = 4;		
        /**治疗技能优先级*/static HEAL=5;
        /**buff技能优先级*/static BUFF=6;
        /**伤害技能优先级*/static HURT=7;
        /**仇恨筛选优先级*/static HATE=8;
		/**距离保护目标最近的敌人*/static MIN_PROTECTED = 9;
        static sortFuncs:((a: GameRole, b: GameRole) => number)[] = [
            PeakType.sortByMinDis, 
            PeakType.sortByMaxHp, 
            PeakType.sortByMinHp, 
            PeakType.sortByMinDis, 
            PeakType.sortByMinDis, 
            PeakType.sortByHeal, 
            PeakType.sortByBuff, 
            PeakType.sortByHurt,
            PeakType.sortByHate
        ];
        public static sortByMaxHp(a:GameRole, b:GameRole):number
		{			
			return a._hp > b._hp?-1:1;
		}
		public static sortByMinHp(a:GameRole, b:GameRole):number
		{
			return a._hp < b._hp?-1:1;
		}
		public static sortByMinDis(a:GameRole, b:GameRole):number
		{
			return a.tempDis < b.tempDis?-1:1;
		}
		public static sortByHeal(a:GameRole, b:GameRole):number
		{			
			if(a._hp < b._hp)
				return -1;
			if(b._hp < a._hp)
				return 1;
			if(a._hpMax < b._hpMax)
				return -1;
			if(b._hpMax < a._hpMax)
				return 1;
			if(a._atk > b._atk)
				return -1;
			if(b._atk > a._atk)
				return 1;
			return a.tempDis < b.tempDis?-1:1;
		}
		public static sortByBuff(a:GameRole, b:GameRole):number
		{
			if(a._atk > b._atk)
				return -1;
			if(b._atk > a._atk)
				return 1;
			if(a._hp < b._hp)
				return -1;
			if(b._hp < a._hp)
				return 1;
			if(a._hpMax < b._hpMax)
				return -1;
			if(b._hpMax < a._hpMax)
				return 1;
			return a.tempDis < b.tempDis?-1:1;
		}
		public static sortByHurt(a:GameRole, b:GameRole):number
		{
			if(a.tempDis < b.tempDis)
				return -1;
			if(b.tempDis < a.tempDis)
				return 1;
			if(a._hp < b._hp)
				return -1;
			if(b._hp < a._hp)
				return 1;
			if(a._atk > b._atk)
				return -1;
			if(b._atk > a._atk)
				return 1;
			return a._hpMax < b._hpMax?-1:1;
		}
        public static sortByHate(a:GameRole, b:GameRole):number
		{
			if(a.tempDis < b.tempDis)
				return -1;
			if(b.tempDis < a.tempDis)
				return 1;
			if(a._hp < b._hp)
				return -1;
			if(b._hp < a._hp)
				return 1;			
			return a._hpMax < b._hpMax?-1:1;
		}
		
    }
}